﻿export default () => {
  const CHANNEL_SOURCE_DIC = [
    { label: "线上推广", value: "01" },
    { label: "线下门店", value: "02" },
    { label: "合作伙伴", value: "03" },
    { label: "广告投放", value: "04" },
    { label: "口碑推荐", value: "05" },
    { label: "其他渠道", value: "06" },
  ];

  const ORDER_SOURCE_DIC = [
    { label: "小程序", value: "01" },
    { label: "公众号", value: "02" },
    { label: "支付宝", value: "03" },
    { label: "微信", value: "04" },
    { label: "抖音", value: "05" },
  ];

  const DISPATCH_MODE_DIC = [
    { label: "派单模式1", value: "01" },
    { label: "派单模式2", value: "02" },
    { label: "派单模式3", value: "03" },
  ];
  const ORDER_STATUS_DIC = [
    { label: "待支付", value: "01" },
    { label: "待派单", value: "02" },
    { label: "待审核", value: "03" },
    { label: "已拒单", value: "04" },
    { label: "待发货", value: "05" },
    { label: "待收货", value: "06" },
    { label: "租用中", value: "07" },
    { label: "待结算", value: "08" },
    { label: "已完成", value: "09" },
    { label: "已关闭", value: "10" },
  ];

  const CHANNEL_GROUP_DIC = [
    { label: "渠道分组1", value: "01" },
    { label: "渠道分组2", value: "02" },
    { label: "渠道分组3", value: "03" },
  ];

  const ZHIMA_CHANNEL_DIC = [
    { label: "芝麻渠道1", value: "01" },
    { label: "芝麻渠道2", value: "02" },
    { label: "芝麻渠道3", value: "03" },
  ];

  const PROMOTION_CHANNEL_DIC = [
    { label: "推广渠道1", value: "01" },
    { label: "推广渠道2", value: "02" },
    { label: "推广渠道3", value: "03" },
  ];

  const IS_NOTARIZATION_DIC = [
    { label: "是", value: "1" },
    { label: "否", value: "0" },
  ];
  const searchOption = ref({
    labelPosition: "top",
    labelWidth: "auto",
    menuPosition: "fixed",
    col: {
      xs: 24,
      sm: 8,
      md: 8,
      lg: 6,
      xl: 4,
      span: 4,
    },
    formConfig: {
      orderNo: {
        label: "订单编号",
        clearable: true,
        component: "el-input",
      },
      goodsName: {
        label: "商品名称",
        clearable: true,
        component: "el-input",
      },
      receiverName: {
        label: "收货人姓名",
        clearable: true,
        component: "el-input",
      },
      receiverPhone: {
        label: "收货人手机号",
        clearable: true,
        component: "el-input",
      },
      shopName: {
        label: "店铺名称",
        clearable: true,
        component: "el-input",
      },
      // 提交时间
      createTime: {
        label: "提交时间",
        component: "el-date-picker",
        type: "daterange",
        format: "YYYY-MM-DD",
        valueFormat: "YYYY-MM-DD",
        clearable: true,
      },
      // 租赁标签
      leaseTag: {
        label: "租赁标签",
        component: "el-input",
        clearable: true,
        isCollapse: true,
      },
      // 渠道来源
      channelSource: {
        label: "渠道来源",
        component: "el-select",
        clearable: true,
        isCollapse: true,
        dicData: CHANNEL_SOURCE_DIC,
        dicProps: { label: "label", value: "value" },
        placeholder: "请选择渠道来源",
      },
      // 订单来源
      orderSource: {
        label: "订单来源",
        component: "el-select",
        clearable: true,
        isCollapse: true,
        dicData: ORDER_SOURCE_DIC,
        dicProps: { label: "label", value: "value" },
        placeholder: "请选择订单来源",
      },
      // 订单模式
      dispatchMode: {
        label: "订单模式",
        component: "el-select",
        clearable: true,
        isCollapse: true,
        dicData: DISPATCH_MODE_DIC,
        dicProps: { label: "label", value: "value" },
        placeholder: "请选择订单模式",
      },
      // 订单状态
      orderStatus: {
        label: "订单状态",
        component: "el-select",
        dicData: ORDER_STATUS_DIC,
        dicProps: { label: "label", value: "value" },
        clearable: true,
        isCollapse: true,
        placeholder: "请选择订单状态",
      },
      // 渠道分组
      channelGroup: {
        label: "渠道分组",
        component: "el-select",
        clearable: true,
        isCollapse: true,
        dicData: CHANNEL_GROUP_DIC,
        dicProps: { label: "label", value: "value" },
        placeholder: "请选择渠道分组",
      },
      // 芝麻渠道
      zhimaChannel: {
        label: "芝麻渠道",
        component: "el-select",
        clearable: true,
        isCollapse: true,
        dicData: ZHIMA_CHANNEL_DIC,
        dicProps: { label: "label", value: "value" },
        placeholder: "请选择芝麻渠道",
      },
      // 推广渠道
      promotionChannel: {
        label: "推广渠道",
        component: "el-select",
        clearable: true,
        isCollapse: true,
        dicData: PROMOTION_CHANNEL_DIC,
        dicProps: { label: "label", value: "value" },
        placeholder: "请选择推广渠道",
      },
      // 是否发起公证
      isNotarization: {
        label: "是否发起公证",
        component: "el-select",
        clearable: true,
        isCollapse: true,
        dicData: IS_NOTARIZATION_DIC,
        dicProps: { label: "label", value: "value" },
        placeholder: "请选择是否发起公证",
      },
    },
    // 支付时间
  });
  const tableOption = ref(
    Utils.tools.deleteSearchConfig({
      // 弹窗宽度
      dialogWidth: "30%",
      // 是否显示编辑按钮
      editBtn: false,
      // 是否显示删除按钮
      delBtn: false,
      // 菜单宽度 单个按钮 52px 按钮容器内边距 8px 例如：4个按钮 = 52 * 4 * 8
      menuWidth: 52 * 3 + 8,
      // 对齐方式
      align: "left",
      column: {
        orderNo: { label: "订单编号", minWidth: 200, display: true },
        isNotarization: {
          label: "是否发起公证",
          minWidth: 120,
          display: true,
          formatter: row => (row.isNotarization === "1" ? "是" : "否"),
        },
        storeName: { label: "店铺名称", minWidth: 220, display: true },
        orderSource: { label: "订单来源", minWidth: 120, display: true },
        channelSource: { label: "渠道来源", minWidth: 120, display: true },
        registerSource: { label: "注册来源", minWidth: 120, display: true },
        dispatchMode: { label: "订单模式", minWidth: 120, display: true },
        goodsName: { label: "商品名称", minWidth: 200, display: true },
        promotionChannel: { label: "推广渠道", minWidth: 120, display: true },
        zhimaChannel: { label: "芝麻渠道", minWidth: 120, display: true },
        channelGroup: { label: "渠道分组", minWidth: 120, display: true },
        paidRentalPeriod: { label: "已支付期数/总期数", minWidth: 150, display: true },
        paidDeposit: { label: "已付押金", minWidth: 100, display: true },
        paidRent: { label: "已付租金", minWidth: 100, display: true },
        refundAmount: { label: "应退金额", minWidth: 100, display: true },
        refundStatus: {
          label: "退款状态",
          minWidth: 120,
          display: true,
          formatter: row => {
            const statusMap = {
              "01": "待退款",
              "02": "已退款",
              "03": "退款中",
              "04": "退款失败",
            };
            return statusMap[row.refundStatus] || row.refundStatus || "-";
          },
        },
        orderStatus: {
          label: "订单状态",
          minWidth: 120,
          display: true,
          formatter: row => {
            const statusMap = {
              "01": "待支付",
              "02": "待派单",
              "03": "待审核",
              "04": "已拒单",
              "05": "待发货",
              "06": "待收货",
              "07": "租用中",
              "08": "待结算",
              "09": "已完成",
              10: "已关闭",
            };
            return statusMap[row.orderStatus] || row.orderStatus || "-";
          },
        },
      },
    })
  );
  return {
    searchOption,
    tableOption,
  };
};
